Skip to content

Conversation

@dmytrostruk
Copy link
Member

@dmytrostruk dmytrostruk commented Dec 31, 2025

Motivation and Context

This PR contains an implementation of create/get API with Provider type for Azure AI V2 chat client, based on Option 2 from this ADR.

Example:

from agent_framework.azure import AzureAIProjectAgentProvider
from azure.ai.projects import AIProjectClient

client = AIProjectClient(endpoint, credential)
provider = AzureAIProjectAgentProvider(client)

# Create new agent on service
agent = await provider.create_agent(name="MyAgent", model="gpt-4", instructions="...")

# Get existing agent by name
agent = await provider.get_agent(agent_name="MyAgent")

# Wrap already-fetched SDK object (no HTTP calls)
agent_ref = await client.agents.get("MyAgent")
agent = provider.as_agent(agent_ref)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Dec 31, 2025
@moonbox3
Copy link
Contributor

moonbox3 commented Jan 5, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai/agent_framework_azure_ai
   _client.py1733579%239–242, 247, 250–253, 258, 261–262, 265, 272, 382, 408–411, 454, 491, 493, 498, 500–501, 503–511, 513
   _provider.py961386%124–125, 209, 214, 286, 330, 365, 416–418, 422–424
   _shared.py1648448%102–111, 158, 174–176, 178–195, 203–206, 209–210, 213–220, 225–226, 232–234, 237–238, 240, 252, 254–255, 257–258, 260–261, 263–271, 273, 308, 310–313, 315, 321, 327, 331, 346, 349–350, 352
packages/core/agent_framework
   _types.py101512787%98, 138, 140, 142, 144, 146, 148, 155–158, 176–177, 314, 316, 323, 342, 382, 428–429, 465, 615, 729–730, 732, 757, 764, 781–783, 868, 873–874, 876, 883–884, 886, 913, 922, 925–927, 932–933, 940, 944–946, 1102, 1191–1194, 1202–1203, 1294, 1475, 1481, 1876, 1892, 1894–1901, 1930, 1963–1965, 1971–1972, 2033, 2288, 2293, 2297, 2301, 2479–2481, 2493, 2532, 2577–2582, 2604, 2609, 3068, 3154–3156, 3229, 3240–3241, 3465–3467, 3470–3472, 3476, 3481, 3485, 3537, 3597–3599, 3627, 3663, 3681, 3685–3687, 3689, 3700–3701, 3704–3708, 3714
TOTAL17033263884% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3048 208 💤 0 ❌ 0 🔥 1m 6s ⏱️

@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Jan 13, 2026
@dmytrostruk dmytrostruk changed the title Python: [WIP] Create/Get Agent API Python: Create/Get Agent API for Azure V2 Jan 13, 2026
@dmytrostruk dmytrostruk marked this pull request as ready for review January 13, 2026 01:35
Copilot AI review requested due to automatic review settings January 13, 2026 01:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new AzureAIProjectAgentProvider class for creating and managing Azure AI agents using the Azure AI Projects SDK V2. This provides a cleaner, provider-based API pattern for agent creation and retrieval.

Changes:

  • Introduces AzureAIProjectAgentProvider with methods: create_agent(), get_agent(), and as_agent()
  • Refactors shared utility functions for tool conversion between Azure AI and Agent Framework formats
  • Updates all Azure AI samples to use the new provider pattern instead of direct client usage
  • Adds comprehensive unit and integration tests for the provider
  • Updates exports and type stubs to include the new provider class

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/packages/azure-ai/agent_framework_azure_ai/_provider.py New provider implementation with create, get, and wrap agent methods
python/packages/azure-ai/agent_framework_azure_ai/_shared.py Shared utilities for tool conversion and response format handling
python/packages/azure-ai/agent_framework_azure_ai/_client.py Refactored to use shared create_text_format_config function
python/packages/azure-ai/agent_framework_azure_ai/__init__.py Updated exports to include AzureAIProjectAgentProvider
python/packages/azure-ai/agent_framework_azure_ai/__init__.pyi Type stub updated with new provider
python/packages/core/agent_framework/azure/__init__.py Lazy import configuration for new provider
python/packages/core/agent_framework/azure/__init__.pyi Type stub for main package
python/packages/azure-ai/tests/test_provider.py Comprehensive unit tests for provider functionality
python/packages/azure-ai/tests/test_azure_ai_client.py Added tests for tool parsing utilities
python/samples/getting_started/agents/azure_ai/*.py (20+ files) All samples updated to use provider pattern
python/samples/getting_started/agents/azure_ai/azure_ai_provider_methods.py New comprehensive sample demonstrating all provider methods
python/samples/getting_started/agents/azure_ai/README.md Updated to describe new provider and sample

model: str | None = None,
instructions: str | None = None,
description: str | None = None,
temperature: float | None = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we can make this typed as well, probably using a subset of the "regular" options.

self._should_close_client = True

self._project_client = project_client
self._credential = credential
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see us using self._credential anywhere. Do we need to hold on to it?

ServiceInitializationError: If required parameters are missing or invalid.
"""
try:
self._settings = AzureAISettings(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The V2 client initialization pattern (settings creation, endpoint/credential validation, AIProjectClient instantiation with user-agent) is now repeated between AzureAIProjectAgentProvider and AzureAIClient. Worth a shared helper, or acceptable given the localized scope?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants